<template>
  <div class="dashboard-container">
    <div class="welcome-section">
      <div class="welcome-card glass-card scale-in">
        <div class="welcome-content">
          <div class="welcome-icon">
            <el-icon :size="60"><HomeFilled /></el-icon>
          </div>
          <h1 class="welcome-title">欢迎使用 DataTK 析语</h1>
          <p class="welcome-subtitle">数据管理平台</p>
          <div class="welcome-time">
            <el-icon><Calendar /></el-icon>
            <span>{{ currentTime }}</span>
          </div>
          <div class="welcome-message">
            <p>尊敬的用户，欢迎登录系统！</p>
            <p>本系统为您提供全面的数据管理和分析功能，助力您做出更明智的决策。</p>
            <p>请点击左侧菜单开始使用系统各项功能。</p>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted, onBeforeUnmount } from 'vue'
import { Calendar, HomeFilled } from '@element-plus/icons-vue'

// 定义组件名称
defineOptions({
  name: 'DashboardView'
})

// 当前时间
const currentTime = ref('')
let timer = null

// 更新时间
const updateTime = () => {
  const now = new Date()
  const year = now.getFullYear()
  const month = String(now.getMonth() + 1).padStart(2, '0')
  const day = String(now.getDate()).padStart(2, '0')
  const hour = String(now.getHours()).padStart(2, '0')
  const minute = String(now.getMinutes()).padStart(2, '0')
  const second = String(now.getSeconds()).padStart(2, '0')

  currentTime.value = `${year}年${month}月${day}日 ${hour}:${minute}:${second}`
}

onMounted(() => {
  updateTime()
  // 每秒更新一次时间
  timer = setInterval(updateTime, 1000)
})

onBeforeUnmount(() => {
  // 组件销毁前清除定时器
  if (timer) {
    clearInterval(timer)
  }
})
</script>

<style scoped>
.dashboard-container {
  padding: 20px;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 200px);
  justify-content: center;
}

.welcome-section {
  display: flex;
  justify-content: center;
}

.welcome-card {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 30px;
  text-align: center;
  border-radius: 12px;
  transition: all var(--transition-normal);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.welcome-icon {
  color: var(--primary-color, #1a73e8);
  margin-bottom: 20px;
  animation: pulse 2s var(--animation-bounce) infinite;
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

.welcome-title {
  font-size: 32px;
  font-weight: 600;
  margin: 0 0 10px;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-fill-color: transparent;
}

.welcome-subtitle {
  font-size: 18px;
  margin: 0 0 20px;
  opacity: 0.8;
}

.welcome-time {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 30px;
  font-size: 16px;
  background: rgba(255, 255, 255, 0.1);
  padding: 8px 16px;
  border-radius: 6px;
  backdrop-filter: blur(4px);
  display: inline-flex;
}

.welcome-time .el-icon {
  margin-right: 8px;
  color: var(--primary-color);
}

.welcome-message {
  max-width: 600px;
  margin: 0 auto;
  line-height: 1.8;
  font-size: 16px;
}

.welcome-message p {
  margin: 10px 0;
  transition: all var(--transition-normal);
}

.welcome-message p:hover {
  transform: translateX(5px);
  color: var(--primary-color);
}

/* 动画效果 */
.scale-in {
  animation: scaleIn 0.5s ease-out forwards;
}

@keyframes scaleIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
</style>
